//
//  TKYCustomChartsCell.m
//  StationHouseHelper
//
//  Created by apple on 2018/7/11.
//  Copyright © 2018年 铁科院. All rights reserved.
//        (x - 1) * 10 + 100 100是基本高度 x是总个数  10是一份儿的高度）


#import "TKYCustomChartsCell.h"
@interface TKYCustomChartsCell(){
    CGFloat height;
}

@property (nonatomic, strong)UILabel *numLabel;

//@property (nonatomic, strong)UIView *progressView;

@property (nonatomic, strong)UILabel *bottonLine;

@property (nonatomic, strong)UILabel *titleLab;
@end
@implementation TKYCustomChartsCell
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
       // self.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.numLabel];
        [self.contentView addSubview:self.progressView];
        [self.contentView addSubview:self.bottonLine];
        [self.contentView addSubview:self.titleLab];
        
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).with.offset(kWidthScale *0);
            make.right.mas_equalTo(self.contentView).with.offset(kWidthScale *0);
            make.bottom.mas_equalTo(self.contentView).with.offset(kHeightScale *0);
            make.height.mas_equalTo(kHeightScale *80);
            //make.width.mas_equalTo(kWidthScale *60);
        }];
        
        [self.bottonLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).with.offset(-kWidthScale *5);
            make.right.mas_equalTo(self.contentView).with.offset(kWidthScale *5);
            make.bottom.mas_equalTo(self.titleLab.mas_top).with.offset(- kHeightScale *0);
            make.height.mas_equalTo(kHeightScale *2);
        }];
        
        [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(kWidthScale *0);
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(kWidthScale *0);
            make.bottom.mas_equalTo(self.progressView.mas_top).with.offset (-kHeightScale *5);
           // make.width.mas_equalTo(kHeightScale *30);
            make.height.mas_equalTo(kHeightScale *20);
            
        }];
        
        [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).with.offset(kWidthScale *20);
            make.right.mas_equalTo(self.contentView).with.offset(-kWidthScale *20);
            make.bottom.mas_equalTo(self.bottonLine.mas_top).with.offset (-kHeightScale *5);
            make.height.mas_equalTo(0);
        }];
        
    }
    return self;
}

- (UILabel *)numLabel{
    if (_numLabel == nil) {
        _numLabel = [[UILabel alloc]init];
        _numLabel.text = @"12";
        _numLabel.textAlignment = NSTextAlignmentCenter;
        _numLabel.font = Font(10);
    }
    return _numLabel;
}

- (UIView *)progressView{
    if (_progressView == nil) {
        _progressView = [[UIView alloc]init];
       // _progressView.backgroundColor =  kRGBColor(34, 130, 255, 1);
        
        }
    return _progressView;
}

- (UILabel *)bottonLine{
    if (_bottonLine == nil) {
        _bottonLine = [[UILabel alloc]init];
        _bottonLine.backgroundColor = kRGBColor(34, 130, 255, 1);
    }
    return _bottonLine;
}

- (UILabel *)titleLab{
    if (_titleLab == nil) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.text = @"项目\n管理";
        _titleLab.textAlignment = NSTextAlignmentCenter;
       // _titleLab.backgroundColor = [UIColor redColor];
        _titleLab.font = Font(9);
        _titleLab.transform = CGAffineTransformMakeRotation(M_PI *90-20);
    }
    return _titleLab;
}

- (void)setQuestionTypeListModel:(TKYQuestionTypeListModel *)questionTypeListModel{
    _questionTypeListModel = questionTypeListModel;
    questionTypeListModel.count = 30;
    [self.progressView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).with.offset(kWidthScale *20);
        make.right.mas_equalTo(self.contentView).with.offset(-kWidthScale *20);
        make.bottom.mas_equalTo(self.bottonLine.mas_top).with.offset (-kHeightScale *5);
        make.height.mas_equalTo(questionTypeListModel.count);
    }];
    //    self.progressView.backgroundColor = [UIColor blueColor];
    //设置view的渐变颜色
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = CGRectMake(0, 0, 20, questionTypeListModel.count);
    gradient.colors = [NSArray arrayWithObjects:(id)kRGBColor(113, 188, 247, 1).CGColor,
                       (id)kRGBColor(109, 177, 248, 1).CGColor,
                       (id)KNavColor.CGColor,
                       nil];
    
    [self.progressView.layer addSublayer:gradient];
    self.numLabel.text = [NSString stringWithFormat:@"%ld",questionTypeListModel.count ];
    self.titleLab.text = questionTypeListModel.name;
}

//-  (void)setNumberStr:(NSString *)numberStr{
//    _numberStr = numberStr;
//    CGFloat aa = [numberStr intValue];
////    if (aa < 100) {
////        aa = aa;
////    }else{
//        aa = aa *.1;
////    }
//   
//    [self.progressView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(self.contentView).with.offset(kWidthScale *10);
//        make.right.mas_equalTo(self.contentView).with.offset(-kWidthScale *10);
//        make.bottom.mas_equalTo(self.bottonLine.mas_top).with.offset (-kHeightScale *5);
//        make.height.mas_equalTo(aa);
//    }];
////    self.progressView.backgroundColor = [UIColor blueColor];
//    //设置view的渐变颜色
//    CAGradientLayer *gradient = [CAGradientLayer layer];
//    gradient.frame = CGRectMake(0, 0, 20, aa);
//    gradient.colors = [NSArray arrayWithObjects:(id)kRGBColor(113, 188, 247, 1).CGColor,
//                       (id)kRGBColor(109, 177, 248, 1).CGColor,
//                       (id)KNavColor.CGColor,
//                        nil];
//    [self.progressView.layer addSublayer:gradient];
//    self.numLabel.text = numberStr;
//}

- (void)redBorderWidth{
    [self.progressView tky_cornerWithRadius:0 borderColor:[UIColor redColor] borderWidth:3];
}

- (void)removRedBorderWidth{
    [self.progressView  tky_cornerWithRadius:0 borderColor:nil borderWidth:0];
}
@end
